require(['./config'], ()=> {
    require(['swiper', 'template', 'header', 'footer'], (Swiper,template) => {
        class Index {
            constructor(){
                this.banner()
                this.getHomeList()
                this.getHomeDynamic()
            }
            banner(){
                var mySwiper = new Swiper ('.swiper-container', {
                    loop: true, // 循环模式选项
                    autoplay: true,
                    speed:2000,
                    // 如果需要分页器
                    pagination: {
                      el: '.swiper-pagination',
                      clickable: true,
                    },
                    autoplay: {
                        delay: 600,
                      },
                  }) 
            }
            getHomeList () {
                $.get('http://rap2.taobao.org:38080/app/mock/264019/api/home/shopImg', resp => {
                    if(resp.code === 200){
                        const { list } = resp.body
                        const html = template('giftListTemplate', { list })
                        $('#giftList').html(html)
                    }
                })
            }
            getHomeDynamic () {
                $.get('http://rap2.taobao.org:38080/app/mock/264019/api/home/dynamic', resp => {
                    if(resp.code === 200){
                        const {list} = resp.body
                        const html = template('giftListTemplate_2', {list})
                        $('#gifList_2').html(html)
                    }
                })
            }
        }
        new Index()
    })
    
})

